//stringbad.h -- flawed string class definition
#include <iostream>
#ifndef STRINGBAD_H_
#define STRINGBAD_H_

class String
{
    private:
        char * str;
        int len;

        static int num_strings;
        static const int CINLIM = 80;

    public:
        String(const char * s);          // constructor
        String();                        // default constructor
        String(const String & st);    // copy constructor
        ~String();

        // static methods
        static int HowMany(){return num_strings;};
        
        // class methods
        int length() const {return len;};

        //= operator
        String & operator=(const String & st); // 赋值运算符
        String & operator=(const char * st);

        char & operator[](int i);                   // 可以通过下标修改String内容
        const char & operator[](int i) const;       // String为常量时也要可用下标访问内容

        //friend function
        friend bool operator<(const String &st, const String &st2);
        friend bool operator>(const String &st, const String &st2);
        friend bool operator==(const String &st, const String &st2);

        friend std::ostream & operator<<(std::ostream & os, const String & st);
        friend std::istream & operator>>(std::istream & is, String & st);






};

#endif
